package com.pm.controller;

import com.pm.common.annotation.Log;
import com.pm.common.core.controller.BaseController;
import com.pm.common.core.domain.AjaxResult;
import com.pm.common.core.page.TableDataInfo;
import com.pm.common.enums.BusinessType;
import com.pm.common.utils.poi.ExcelUtil;
import com.pm.domain.PmAppointment;
import com.pm.service.IPmAppointmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 预约管理Controller
 * 
 * @author li
 * @date 2025-09-22
 */
@RestController
@RequestMapping("/order/appointment")
public class PmAppointmentController extends BaseController
{
    @Autowired
    private IPmAppointmentService pmAppointmentService;

    /**
     * 查询预约管理列表
     */
    @PreAuthorize("@ss.hasPermi('order:appointment:list')")
    @GetMapping("/list")
    public TableDataInfo list(PmAppointment pmAppointment)
    {
        startPage();
        List<PmAppointment> list = pmAppointmentService.selectPmAppointmentList(pmAppointment);
        return getDataTable(list);
    }

    /**
     * 导出预约管理列表
     */
    @PreAuthorize("@ss.hasPermi('order:appointment:export')")
    @Log(title = "预约管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PmAppointment pmAppointment)
    {
        List<PmAppointment> list = pmAppointmentService.selectPmAppointmentList(pmAppointment);
        ExcelUtil<PmAppointment> util = new ExcelUtil<PmAppointment>(PmAppointment.class);
        util.exportExcel(response, list, "预约管理数据");
    }

    /**
     * 获取预约管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('order:appointment:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(pmAppointmentService.selectPmAppointmentById(id));
    }

    /**
     * 新增预约管理
     */
    @PreAuthorize("@ss.hasPermi('order:appointment:add')")
    @Log(title = "预约管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PmAppointment pmAppointment)
    {
        return toAjax(pmAppointmentService.insertPmAppointment(pmAppointment));
    }

    /**
     * 修改预约管理
     */
    @PreAuthorize("@ss.hasPermi('order:appointment:edit')")
    @Log(title = "预约管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PmAppointment pmAppointment)
    {
        return toAjax(pmAppointmentService.updatePmAppointment(pmAppointment));
    }

    /**
     * 删除预约管理
     */
    @PreAuthorize("@ss.hasPermi('order:appointment:remove')")
    @Log(title = "预约管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(pmAppointmentService.deletePmAppointmentByIds(ids));
    }


}
